package com.pms.house;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import com.espirit.eap.ICheckModelDuplicateInfo;
import com.espirit.eap.PinyinAware;
import com.espirit.eap.annotation.DomainModel;
import com.espirit.eap.annotation.ModelDisplayProperty;

@Entity
@DomainModel
@ModelDisplayProperty("name")
public class Building implements Serializable, ICheckModelDuplicateInfo, PinyinAware{

	private static final long serialVersionUID = -6415752210370880626L;

	private Integer id;
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@ManyToOne(targetEntity = Garden.class, fetch = FetchType.LAZY)
	public Garden getGarden() {
		return garden;
	}

	public void setGarden(Garden garden) {
		this.garden = garden;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	private Garden garden;
	private String name;
	private String remark;
	
	private final static String[] gatherProperties = new String[]{"name"};
	@Override
	public String[] gatherProperties() {
		return gatherProperties;
	}
	
	private String pinyin;

	public String getPinyin() {
		return pinyin;
	}

	public String source() {
		return name;
	}

	@Override
	public void setPinyin(String pinyin) {
		this.pinyin = pinyin;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Building other = (Building) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	
}
